package com.study.boot.event.pub;

import com.study.boot.event.AnotherEvent;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author fangdengfu
 * @date 2020/7/4 9:59
 */
@Component
public class AnotherPublisher implements ApplicationContextAware {

    private ApplicationContext ctx;


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.ctx = applicationContext;
    }

    public void publishEvent(String json) {
        this.ctx.publishEvent(new AnotherEvent(json));
    }

}

